from selenium import webdriver
from unittest import TestCase
import time

# class Test_line(TestCase):
#     def testLogin1(self):
username = "deng"  # 用户名
name = "邓学超"  # 姓名
password = "123456"  # 密码
age = 21  # 年龄
mailbox = "925204100@qq.com"  # 邮箱
number = "17319034162"  # 号码
address = "月球，和嫦娥是邻居"
# expect = "Student Login"
driver = webdriver.Chrome()
driver.get("http://localhost:8080/HKR/")
driver.maximize_window()
driver.find_element_by_xpath(r'/html/body/div/div/div[1]/div[2]/a[1]').click()
driver.find_element_by_xpath(r'//*[@id="loginname"]').send_keys(username)
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="msform"]/fieldset[1]/input[2]').send_keys(name)
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="pwd"]').send_keys(password)
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="msform"]/fieldset[1]/input[4]').send_keys(password)
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="msform"]/fieldset[1]/input[5]').click()
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="valid_age"]').send_keys(age)
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="msform"]/fieldset[2]/select[1]').send_keys("男")
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="classname"]').send_keys("Python自动化")
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="msform"]/fieldset[2]/input[3]').click()
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="reg_mail"]').send_keys(mailbox)
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="reg_phone"]').send_keys(number)
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="msform"]/fieldset[3]/textarea').send_keys(address)
time.sleep(1)
driver.find_element_by_xpath(r'//*[@id="btn_reg"]').click()
time.sleep(1)
driver.switch_to.alert.accept()
